<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>experimental::make_parallel_group (3 of 3 overloads)</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../boost_asio.html" title="Boost.Asio">
<link rel="up" href="../experimental__make_parallel_group.html" title="experimental::make_parallel_group">
<link rel="prev" href="overload2.html" title="experimental::make_parallel_group (2 of 3 overloads)">
<link rel="next" href="../experimental__parallel_group.html" title="experimental::parallel_group">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="overload2.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../experimental__make_parallel_group.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../boost_asio.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../experimental__parallel_group.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="boost_asio.reference.experimental__make_parallel_group.overload3"></a><a class="link" href="overload3.html" title="experimental::make_parallel_group (3 of 3 overloads)">experimental::make_parallel_group
        (3 of 3 overloads)</a>
</h4></div></div></div>
<p>
          Create a group of operations that may be launched in parallel.
        </p>
<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span>
    <span class="keyword">typename</span> <span class="identifier">Allocator</span><span class="special">,</span>
    <span class="keyword">typename</span> <span class="identifier">Range</span><span class="special">&gt;</span>
<span class="identifier">ranged_parallel_group</span><span class="special">&lt;</span> <span class="identifier">decay_t</span><span class="special">&lt;</span> <span class="identifier">Range</span> <span class="special">&gt;,</span> <span class="identifier">Allocator</span> <span class="special">&gt;</span> <span class="identifier">make_parallel_group</span><span class="special">(</span>
    <span class="identifier">allocator_arg_t</span> <span class="special">,</span>
    <span class="keyword">const</span> <span class="identifier">Allocator</span> <span class="special">&amp;</span> <span class="identifier">allocator</span><span class="special">,</span>
    <span class="identifier">Range</span> <span class="special">&amp;&amp;</span> <span class="identifier">range</span><span class="special">,</span>
    <span class="identifier">constraint_t</span><span class="special">&lt;</span> <span class="identifier">is_async_operation_range</span><span class="special">&lt;</span> <span class="identifier">decay_t</span><span class="special">&lt;</span> <span class="identifier">Range</span> <span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">value</span> <span class="special">&gt;</span>  <span class="special">=</span> <span class="number">0</span><span class="special">);</span>
</pre>
<h6>
<a name="boost_asio.reference.experimental__make_parallel_group.overload3.h0"></a>
          <span class="phrase"><a name="boost_asio.reference.experimental__make_parallel_group.overload3.parameters"></a></span><a class="link" href="overload3.html#boost_asio.reference.experimental__make_parallel_group.overload3.parameters">Parameters</a>
        </h6>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">allocator</span></dt>
<dd><p>
                Specifies the allocator to be used with the result vectors.
              </p></dd>
<dt><span class="term">range</span></dt>
<dd><p>
                A range containing the operations to be launched.
              </p></dd>
</dl>
</div>
<p>
          For example:
        </p>
<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">op_type</span> <span class="special">=</span>
  <span class="keyword">decltype</span><span class="special">(</span><span class="identifier">socket1</span><span class="special">.</span><span class="identifier">async_read_some</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer</span><span class="special">(</span><span class="identifier">data1</span><span class="special">)));</span>

<span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">op_type</span><span class="special">&gt;</span> <span class="identifier">ops</span><span class="special">;</span>
<span class="identifier">ops</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">socket1</span><span class="special">.</span><span class="identifier">async_read_some</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer</span><span class="special">(</span><span class="identifier">data1</span><span class="special">)));</span>
<span class="identifier">ops</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">socket2</span><span class="special">.</span><span class="identifier">async_read_some</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer</span><span class="special">(</span><span class="identifier">data2</span><span class="special">)));</span>

<span class="identifier">boost</span><span class="special">::</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">experimental</span><span class="special">::</span><span class="identifier">make_parallel_group</span><span class="special">(</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">allocator_arg_t</span><span class="special">,</span>
    <span class="identifier">my_allocator</span><span class="special">,</span>
    <span class="identifier">ops</span>
  <span class="special">).</span><span class="identifier">async_wait</span><span class="special">(</span>
    <span class="identifier">boost</span><span class="special">::</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">experimental</span><span class="special">::</span><span class="identifier">wait_for_all</span><span class="special">(),</span>
    <span class="special">[](</span>
        <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;</span> <span class="identifier">completion_order</span><span class="special">,</span>
        <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">system</span><span class="special">::</span><span class="identifier">error_code</span><span class="special">&gt;</span> <span class="identifier">e</span><span class="special">,</span>
        <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;</span> <span class="identifier">n</span>
      <span class="special">)</span>
    <span class="special">{</span>
      <span class="keyword">for</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="identifier">completion_order</span><span class="special">.</span><span class="identifier">size</span><span class="special">();</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
      <span class="special">{</span>
        <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">idx</span> <span class="special">=</span> <span class="identifier">completion_order</span><span class="special">[</span><span class="identifier">i</span><span class="special">];</span>
        <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"socket "</span> <span class="special">&lt;&lt;</span> <span class="identifier">idx</span> <span class="special">&lt;&lt;</span> <span class="string">" finished: "</span><span class="special">;</span>
        <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">e</span><span class="special">[</span><span class="identifier">idx</span><span class="special">]</span> <span class="special">&lt;&lt;</span> <span class="string">", "</span> <span class="special">&lt;&lt;</span> <span class="identifier">n</span><span class="special">[</span><span class="identifier">idx</span><span class="special">]</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span><span class="special">;</span>
      <span class="special">}</span>
    <span class="special">}</span>
  <span class="special">);</span>
</pre>
</div>
<div class="copyright-footer">Copyright © 2003-2025 Christopher M.
      Kohlhoff<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="overload2.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../experimental__make_parallel_group.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../boost_asio.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../experimental__parallel_group.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
